package cn.wxz1997.permission.controller;

import cn.wxz1997.permission.dto.RoleForm;
import cn.wxz1997.permission.model.Role;
import cn.wxz1997.permission.service.RoleService;
import cn.wxz1997.permission.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: ${todo}
 * @Author: wxz1997
 * @Date 18-9-2下午2:51
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping
    public Result<List<Role>> list(){
        return Result.success(roleService.list());
    }

    @PostMapping
    public Result<Role> add(@RequestBody RoleForm roleForm){
        return Result.success(roleService.add(roleForm));
    }

    @PutMapping("/{id}")
    public Result<Role> update(@RequestBody RoleForm roleForm){
        return Result.success(roleService.update(roleForm));
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        return Result.success(roleService.delete(id));
    }
}
